﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace XChipMatlab
{
    using XChipRegisterGen;
    using MathWorks.MATLAB.NET.Arrays;
    using MathWorks.MATLAB.NET.Utility;
    using XChipRegisterGenUserNative;

    public class XChipRegister
    {
        public RegisterGen registerGen;

        public RegisterGenUser registerGenUser;
        public XChipRegister() {
            registerGen = new RegisterGen();
            registerGenUser = new RegisterGenUser();
        }
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }

        public string[] RegisterGen(string _file_name, string _paramter_path) {
            string[] strList = new string[1];
            MWArray file_name = (MWCharArray)_file_name;
            MWArray paramter_path = (MWCharArray)_paramter_path;
            var registerArr = registerGen.register_gen(1,file_name, paramter_path);
            for (int i = 0; i < registerArr.Count(); i++)
            {
                strList[i] = registerArr[i].ToString();
            }
            return strList;
        }
        public string RegisterGenUser(double[] _noise_x_node_list, double[] _offset_lf, double[] _limit_up, double[] _offset_rt, string _file_name) {
            //string str = string.Empty;
            MWArray noise_x_node_list = (MWNumericArray)_noise_x_node_list;
            MWArray offset_lf = (MWNumericArray)_offset_lf;
            MWArray limit_up = (MWNumericArray)_limit_up;
            MWArray offset_rt = (MWNumericArray)_offset_rt;
            MWArray file_name = (MWCharArray)_file_name;
            var registerArr = registerGenUser.register_gen_user(1, noise_x_node_list, offset_lf, limit_up, offset_rt, file_name);
            if (registerArr.Count() > 0)
            {
                return registerArr[0].ToString();
            }
            else {
                return string.Empty;
            }
        }
    }
}
